package com.onec.service.customer.entity.merchant;


import com.fasterxml.jackson.annotation.JsonFormat;
import com.onec.service.api.enums.ProductEnum;
import com.onec.service.api.enums.StatusEnum;
import lombok.Data;
import org.springframework.data.annotation.CreatedDate;
import org.springframework.data.annotation.LastModifiedDate;

import javax.persistence.*;
import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Date;

/**
 * 在线订单实体
 * 通道费率信息。
 *
 * @author ONEC
 */
@Data
@Entity
@Table(name = "t_merchant_fee")
public class MerchantFee implements Serializable {

    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Column(name = "id", unique = true)
    private Long id;

    @Column(name = "version", length = 8)
    @Version
    private Integer version;

    /**
     * 通道编号id
     */
    @Column(name = "merchant_id", length = 16)
    private Long merchantId;

    /**
     * 产品编号
     */
    @Column(name = "product", length = 8)
    @Enumerated(EnumType.STRING)
    private ProductEnum product;

    /**
     * 交易费率
     */
    @Column(name = "rate", length = 8, scale = 4)
    private BigDecimal rate;

    /**
     * 提现费率
     */
    @Column(name = "fee", length = 8, scale = 2)
    private BigDecimal fee;

    /**
     * 创建时间
     */
    @Column(name = "create_time", length = 0)
    @CreatedDate
    @Temporal(TemporalType.TIMESTAMP)
    @JsonFormat(pattern = "yyyy-MM-dd HH:ss:mm", timezone = "GTM+8")
    private Date createTime;
    /**
     * 创建时间
     */
    @Column(name = "update_time", length = 0)
    @LastModifiedDate
    @Temporal(TemporalType.TIMESTAMP)
    @JsonFormat(pattern = "yyyy-MM-dd HH:ss:mm", timezone = "GTM+8")
    private Date updateTime;
    /**
     * 通道状态
     */
    @Column(name = "status", length = 12)
    @Enumerated(EnumType.STRING)
    private StatusEnum status;
    /**
     * 银行名称
     */
    @Column(name = "creator", length = 64)
    private String creator;
    /**
     * 产品备注
     */
    @Column(name = "remarks", length = 64)
    private String remarks;


    public MerchantFee() {
    }

    public MerchantFee(Integer version, Long merchantId, ProductEnum product, BigDecimal rate,
                       BigDecimal fee, Date createTime, Date updateTime, StatusEnum status,
                       String creator, String remarks) {
        this.version = version;
        this.merchantId = merchantId;
        this.product = product;
        this.rate = rate;
        this.fee = fee;
        this.createTime = createTime;
        this.updateTime = updateTime;
        this.status = status;
        this.creator = creator;
        this.remarks = remarks;
    }


}
